package org.java.innerClass01;

public class Sequence {
	
	private Object[] objects;
	private int next = 0;
	
	public Sequence(int size) {
		objects = new Object[size];
	}
	
	public void add(Object x){
		if(next < objects.length){
			objects[next++] = x;
		}
	}
	
	
	private class SSelector implements Selector{
		
		private int i = 0;

		@Override
		public boolean end() {
			return i == objects.length;
		}

		@Override
		public Object current() {
			return objects[i];
		}

		@Override
		public void next() {
			if(i<objects.length){
				i++;
			}
		}
		
	}
	
	public Selector getSelector(){
		return new SSelector();
	}
	
	
	public static void main(String[] args) {
		Sequence sequence = new Sequence(10);
		
		Selector selector = sequence.getSelector();
		
		while (!selector.end()) {
		   System.out.println(selector.current());
		   selector.next();
		}
	}

}
